#!/usr/bin/env python
import sys,re

pat = re.compile("""^<script type="text/javascript" src="([^"]*)"></script>$""")

if len(sys.argv) > 1:
    srcfile=file(sys.argv[1])
else:
    srcfile=sys.stdin

for l in srcfile:
    r = pat.match(l)
    if r is not None:
        jsfile = file(r.groups()[0])
        sys.stdout.write("""<script type="text/javascript">\n""")
        for j in jsfile:
            sys.stdout.write(j)
        sys.stdout.write("""</script>""")
        jsfile.close()
    else:
        sys.stdout.write(l)
